Ext.define('App.datacollection.taskinstance.view.TaskInstanceList', {
    extend: 'Extend.grid.CrudGridPanel',
    alias: 'widget.TaskInstanceList',
    requires: ['App.datacollection.taskinstance.model.TaskInstanceViewModel'],
    viewModel: 'TaskInstanceViewModel',
    bind: {
        store: '{Query}',
        columns: '{columns}',
        search: '{search}'
    },
    config: {
        tbar: {
            showlog: {
                text: '日志',
                handler: function () {
                    var datas = this.up("TaskInstanceList").getSelection();
                    if (datas.length == 1) {
                        Ext.create('App.datacollection.executelog.view.ExecuteLogDataWindow', {taskInstanceId: datas[0].get("id")}).show();
                    } else if (datas.length > 1) {
                        Extend.Msg
                            .error(
                                '提示',
                                '请选择您需要查看日志的任务！');
                    } else {
                        Extend.Msg
                            .error(
                                '提示',
                                '一次只能选择一条任务查看日志！');
                    }
                }
            },
            quickCreate: {
                hidden: true
            },
            add: {
                hidden: true
            },
            edit: {
                hidden: true
            },
            remove: {
                hidden: true
            }
        }
    },
    editor: {
        formClazz: 'App.datacollection.taskinstance.view.TaskInstanceEditor',
        save: 'collection/task_result/save',
        get: 'collection/task_result/get_by_id',
        del: 'collection/task_result/deletes',
        model: 'App.datacollection.taskinstance.model.TaskInstanceModel'
    },
    addHandler: function () {
        this.editHandler(null, false, {
            project: {
                id: this.projectId
            },
            repeatMode: '每周',
            disabled: false
        });
    }
});